﻿using System.Web.Security;

namespace GiveAQuiz.Web.Membership
{
  /// <summary>
  /// This interface defines the methods neccessary for interacting
  /// with the Membership Provider.
  /// </summary>
  public interface IMembershipService
  {
    /// <summary>
    /// Gets the mimimum password length.
    /// </summary>
    int MinPasswordLength { get; }

    /// <summary>
    /// Gets the MembershipUser that is currently signed in
    /// (if one exists)
    /// </summary>
    MembershipUser CurrentUser { get; }
    
    /// <summary>
    /// Retrieve a user based on their user name.
    /// </summary>
    /// <param name="userName">The user name to search for.</param>
    /// <returns>The corresponding MembershipUser.</returns>
    MembershipUser GetUser(string userName);

    /// <summary>
    /// Retrieve a user based on their email.
    /// </summary>
    /// <param name="email">The email to search for.</param>
    /// <returns>The corresponding MembershipUser.</returns>
    MembershipUser GetUserByEmail(string email);
    
    /// <summary>
    /// Validate a User based on their user name and password.
    /// </summary>
    /// <param name="userName">The user name.</param>
    /// <param name="password">The password.</param>
    /// <returns>true if the user can be validated; otherwise false.</returns>
    bool ValidateUser(string userName, string password);
    
    /// <summary>
    /// Create a User.
    /// </summary>
    /// <param name="userName">The desired user name.</param>
    /// <param name="password">The requested password.</param>
    /// <param name="email">The user's email address.</param>
    /// <returns>An MembershipCreateStatus enumeration containing
    /// the response code.</returns>
    MembershipCreateStatus CreateUser(string userName, string password, string email);
    
    /// <summary>
    /// Update a User.
    /// </summary>
    /// <param name="user">The User to update.</param>
    void UpdateUser(MembershipUser user);

    /// <summary>
    /// Change the password for a given User.
    /// </summary>
    /// <param name="userName">The user name requesting the password change.</param>
    /// <param name="oldPassword">The user's original password.</param>
    /// <param name="newPassword">The requested new password.</param>
    /// <returns>true if the password was successfully changed; 
    /// otherwise false.</returns>
    bool ChangePassword(string userName, string oldPassword, string newPassword);

     /// <summary>
    /// Resets the password for a User.
    /// </summary>
    /// <param name="userName">The user name.</param>
    /// <returns>The new password.</returns>
    string ResetPassword(string userName);
  }
}
